home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / DRIVES.SWG / 0048_EXISTDD Update.pas < prev    next >
Pascal/Delphi Source File  |  1993-10-28  |  4KB  |  117 lines

  1. { Updated DRIVES.SWG on October 13, 1993 }
  2.  
  3. { This give all the info on a bootable drive }
  4. { it replaces the EXIST-DD in DRIVES.SWG which DID NOT work }
  5. { updated by GDAVIS 10/13/93 }
  6.  
  7. Uses
  8.   Crt,Dos;
  9.  
  10. Type
  11.   bootrecptr = ^bootRecord;
  12.   bootRecord = Record
  13.        nj       : Array[0..2] of Byte;       {offset  0   Near jump code   }
  14.        oem      : Array[0..7] of Byte;       {        3   OEM name and ver }
  15.        Bytesec  : Word;                      {       11   Bytes/Sector     }
  16.        sectclus : Byte;                      {       13   Sectors/cluster  }
  17.        ressect  : Word;                      {       14   Reserved sectors }
  18.        fattables: Byte;                      {       16   FAT tables       }
  19.        direntrys: Word;                      {       17   Directory entries}
  20.        logsec   : Word;                      {       19   Logical sectors  }
  21.        MDS      : Byte;                      {       21   Media descriptor }
  22.        FatSects : Word;                      {       22   FAT sectors      }
  23.        Secstrak : Word;                      {       24   Sectors/track    }
  24.        NumHeads : Word;                      {       26   Number of heads  }
  25.        HidnSecs : Word;                      {       28   Hidden sectors   }
  26.        bootcode : Array[0..415] of Byte;     {       30   boot code        }
  27.        partcode : Array[0..15] of Byte;      {      446   partition info   }
  28.        bootcode2: Array[0..49] of Byte;      {      462   rest of boot code}
  29.      end;
  30.  
  31. Var
  32.   boot : bootRecord;      { the boot Record Variable }
  33.  
  34.   FUNCTION DiskRead (Drive : CHAR; SSect, NSect : WORD; VAR Buffer) : WORD;
  35.     { Read absolute disk sectors }
  36.  
  37.   VAR
  38.       kbuff  : ARRAY [0..$1f] OF BYTE; {Read Ralf Brown's interrupt listing}
  39.       kPtr   : POINTER;                {Int 25h - ES:[BP+1E] may change    }
  40.       bufPtr : POINTER;
  41.  
  42.   BEGIN
  43.  
  44.     kPtr   := @kbuff;
  45.     BufPtr := @buffer;
  46.  
  47.     Asm
  48.       push  es
  49.       push  bp
  50.       push  di
  51.       les   di, kPtr       { move past first 31 bytes   }
  52.       mov   al, drive      { Gets the passed parameter. }
  53.       AND   al, 1fh        { Cvt from ASCII to drive num }
  54.       DEC   al             { Adjust because A: is drive 0 }
  55.       mov   cx, nsect      { number of sectors to read }
  56.       mov   dx, ssect      { starting at sector.. }
  57.       push  ds
  58.       lds   bx, bufptr      { Get the address of the buffer }
  59.       mov   bp, di
  60.       push  si
  61.       INT   25h            { Do the drive read. }
  62.       pop   si             { Remove the flags int 25h leaves on stack}
  63.       pop   si
  64.       pop   ds
  65.       pop   di
  66.       pop   bp
  67.       pop   es
  68.       jc    @1
  69.       mov   @result, 0       { No errors, so set Function to zero }
  70.       jmp   @Escape
  71.       @1 :
  72.       mov   @result, ax
  73.  
  74.     @Escape :
  75.     END;
  76.   END;
  77.  
  78. Procedure bootlook(Drive : Char);
  79. Var
  80.   ReadResult : WORD;
  81.   I          : Integer;
  82. begin
  83.   { Get diskette info }
  84.   ReadResult := DiskRead(Drive,0,1,boot);
  85.   if ReadResult <> 0 then
  86.   begin
  87.   { Error code here , there are LOTS of them.. see a good DOS book
  88.     most common will be :
  89.     2 = Drive NOT ready
  90.     7 = unknown media .. not a boot disk
  91.     8 = sector not found .. not a boot disk }
  92.   Writeln(LO(ReadResult));
  93.   end
  94.   else
  95.   begin
  96.   WITH Boot DO
  97.   BEGIN
  98.   { I'll just print a few of the possible items }
  99.   Write('OEM         :  ');
  100.   FOR I := 0 TO 7 DO WRITE(CHR(OEM[i]));
  101.   Writeln;
  102.   WriteLn('Dir Entrys  : ',DirEntrys : 4);
  103.   WriteLn('Fat Tables  : ',FatTables : 4);
  104.   WriteLn('Num Heads   : ',NumHeads : 4);
  105.   WriteLn('Secs p/Trk  : ',SecsTrak : 4);
  106.   WriteLn('Hidden Secs : ',HidnSecs : 4);
  107.   END;
  108.   end;
  109.  
  110. end;  { Procedure bootlook }
  111.  
  112. BEGIN
  113. ClrScr;
  114. BootLook('B');  { if drive isn't bootable, you'll get an error (7) }
  115. Readkey;        { try it, this is a safe procedure                 }
  116. END.
  117.